package bj.yanchao.com.dagger2_example.module;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * ${TODO} What the class does
 *
 * @author： yanchao
 * @date： 6/3/16-10:52 PM
 * ${TAGS}
 */
@Module
public class ApplicationModule {
    private final Application application;

    public ApplicationModule(Application application) {
        this.application = application;
    }

    @Provides
    @Singleton
    Context provideApplicationContext() {
        return application.getApplicationContext();
    }

    @Provides
    SharedPreferences provideSharedPreference(){
        return application.getSharedPreferences("all",Context.MODE_PRIVATE);
    }
    @Provides
    SharedPreferences.Editor provideEditor(SharedPreferences v_preferences){
        return v_preferences.edit();
    }

}
